import java.util.LinkedList;
import java.util.List;

/*
    抽象CPU
 */
public class CPU {
    //调度策略
    private Policy policy;
    //是否忙
    private boolean busy;
    //当前运行的线程ID
    private int nowProcessID;
    //等待队列
    private List<Process> ReadyList = new LinkedList<>();

    public void executeProcess(Process process) {
        int PC = process.getProgressCount();
        WorkUnit workUnit = process.getProcessWork().get(PC);
        if (workUnit.isUseCPU()) {
            //CPU操作
            if (workUnit.getCPUWork().equals("访存")) {
                MMU mmu = MMU.getMmu();
                mmu.getPhysical(workUnit.getPageNum(),workUnit.getPageOffset());
            } else {
                //进程操作
                String processWork =workUnit.getProcessWork();
                if(processWork.equals("create")){

                }else if(processWork.equals("stop")){
                    process.setProgressCount(-1);
                    return;
                }
            }
        } else {
            //磁盘操作


        }

    }

    public void saveContext() {

    }

    public void recoveryContext() {

    }
}
